//
//  HJChatBaseCell.m
//  XWC
//
//  Created by Hello on 2022/11/3.
//

#import "HJChatBaseCell.h"
#import "HJChatMessageModel.h"
#import "HJChatMessageLayout.h"

@implementation HJChatBaseCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.backgroundColor = UIColor.tj_F6F6F6Color;
        self.contentView.backgroundColor = UIColor.tj_F6F6F6Color;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        UILabel *timeLabel = [UILabel lableWithSuperView:self.contentView font:UIFontMake(12) color:UIColor.tj_BEBDCAColor title:nil textAlignment:NSTextAlignmentCenter];
        timeLabel.hidden = YES;
        
        _timeLabel = timeLabel;
    }
    return self;
}


- (void)layoutSubviews {
    [super layoutSubviews];
        
    self.timeLabel.frame = self.messageLayout.timeLabelRect;
}

- (void)setMessageLayout:(HJChatMessageLayout *)messageLayout {
    _messageLayout = messageLayout;
    
    _timeLabel.hidden = !messageLayout.isShowTime;
    if (!_timeLabel.hidden) {
        //        _timeLabel.text = [[NSDate dateWithTimeIntervalSince1970:messageLayout.messageModel.timestamp.integerValue / 1000] stringWithFormat:@"MM-dd HH:mm:ss"];
        _timeLabel.text = [HJTools convertDateChatCellToString:[NSDate dateWithTimeIntervalSince1970:messageLayout.messageModel.timestamp.integerValue / 1000]];
    } else {
        _timeLabel.text = nil;
    }
}

@end
